#include "Command.h"

#include <iostream>
#include <string>

using namespace std;

const Command Command::EndOfParameter("EndOfParameter");
const Command Command::OkOfConfig("OkOfConfig");
const Command Command::ErrorOfConfig("ErrorOfConfig");
const Command Command::Run("Run");
const Command Command::Running("Running");
const Command Command::EndOfRun("EndOfRun");

ostream& Command::WriteToStream(ostream& os) const
{
	string::const_iterator p = mValue.begin();
	while(p != mValue.end())
	{
		os.put(*p++);
	}

	return os;
}

istream& Command::ReadFromStream(istream& is)
{
	is >> mValue;
	return is;
}

ostream& Command::WriteBinary(ostream& os) const
{
	os.write(mValue.data(), mValue.size());
	os.put('\0');
	return os;
}

istream& Command::ReadBinary(istream& is)
{
	return getline(is, mValue, '\0');
}